package com.xinqi.modules.stats.studyanalysis.controller.web;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.course.course.client.RemoteCourseClient;
import com.xinqi.modules.course.course.dto.rsp.CourseResultDTO;
import com.xinqi.modules.stats.studyanalysis.dto.req.StudentAnalysisQueryDTO;
import com.xinqi.modules.stats.studyanalysis.dto.req.StudentInfoAnalysisQueryDTO;
import com.xinqi.modules.stats.studyanalysis.dto.req.StudyAnalysisExportDTO;
import com.xinqi.modules.stats.studyanalysis.dto.rsp.StudentAnalysisContentResultDTO;
import com.xinqi.modules.stats.studyanalysis.dto.rsp.StudyAnalysisVo;
import com.xinqi.modules.stats.studyanalysis.service.StudyAnalysisService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.ClassPathResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 学勤分析web
 *
 * @author: 星星
 * @date: 2023/03/26
 */
@Tag(name = "学勤分析web", description = "学勤分析web")
@RestController
@RequestMapping("/web/studyanalysis")
@RequiredArgsConstructor
@Slf4j
public class StudyAnalysisWebController {
    private final StudyAnalysisService studyAnalysisService;

    /**
     * 整体分析
     *
     * @Author 星星
     * @Date 15:02 2023/3/22
     * @Return
     * @Exception
     */
    @GetMapping("/wholeAnalysis/{classId}")
    public R wholeAnalysis(@PathVariable("classId") Long classId) {
        List<StudyAnalysisVo> res = studyAnalysisService.wholeAnalysis(classId);
        return R.ok(res);
    }

    /**
     * 学生整体分析
     *
     * @Author 星星
     * @Date 15:02 2023/3/22
     * @Return
     * @Exception
     */
    @GetMapping("/studentAnalysis")
    public R studentAnalysis(@Validated StudentAnalysisQueryDTO analysisQueryDTO) {
        Map<String, Object> res = studyAnalysisService.studentAnalysis(analysisQueryDTO);
        return R.ok(res);
    }

    /**
     * 学生详情分析
     *
     * @Author 星星
     * @Date 15:02 2023/3/27
     * @Return
     * @Exception
     */
    @GetMapping("/studentInfoAnalysis")
    public R studentInfoAnalysis(@Validated StudentInfoAnalysisQueryDTO analysisQueryDTO) {
        Map<String, Object> res = studyAnalysisService.studentInfoAnalysis(analysisQueryDTO);
        return R.ok(res);
    }

    /**
     * 下载学情分析
     * @Author 星星
     * @Date 15:02 2023/04/04
     * @Return
     * @Exception
     */
    @GetMapping("/StudyAnalysisExport")
    public void StudyAnalysisExport(@Validated StudyAnalysisExportDTO exportDTO, HttpServletResponse response) {
        studyAnalysisService.studyAnalysisExport(exportDTO, response);
    }
}
